﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="OptionParameterTest.cs" company="Matthias Friedrich">
//   Copyright © Matthias Friedrich 2013
// </copyright>
// --------------------------------------------------------------------------------------------------------------------

namespace CommandLineHandling.UnitTest
{
    using System;

    using CommandlineHandling;

    using Microsoft.VisualStudio.TestTools.UnitTesting;

    [TestClass]
    public class OptionParameterTest
    {
        public TestContext TestContext { get; set; }

        [TestMethod]
        public void op_DateTime_ExplicitTest1()
        {
            var p = new OptionParameter() { Value = "2011/08/01" };

            var expected = new DateTime(2011, 08, 01);

            var actual = (DateTime)p;

            Assert.AreEqual(expected, actual);
        }

        [TestMethod]
        public void op_DateTime_ExplicitTest2()
        {
            var p = new OptionParameter() { Value = "01.08.2011" };

            var expected = new DateTime(2011, 08, 01);

            var actual = (DateTime)p;

            Assert.AreEqual(expected, actual);
        }

        [TestMethod]
        public void op_ExplicitTest()
        {
            var p = new OptionParameter() { Value = "1,45" };

            const double Expected = 1.45D;

            var actual = (double)p;

            Assert.AreEqual(Expected, actual);
        }

        [TestMethod]
        public void op_ExplicitTest1()
        {
            var p = new OptionParameter() { Value = "1,45" };

            const float Expected = 1.45F;

            var actual = (float)p;

            Assert.AreEqual(Expected, actual);
        }

        [TestMethod]
        public void op_ExplicitTest3()
        {
            var p = new OptionParameter() { Value = "1,45" };

            const decimal Expected = 1.45M;

            var actual = (Decimal)p;

            Assert.AreEqual(Expected, actual);
        }

        [TestMethod]
        public void op_ExplicitTest4()
        {
            var p = new OptionParameter() { Value = "1" };

            const int Expected = 1;

            var actual = (int)p;

            Assert.AreEqual(Expected, actual);
        }

        [TestMethod]
        public void op_ExplicitTest5()
        {
            var p = new OptionParameter() { Value = "true" };

            const bool Expected = true;

            var actual = (bool)p;

            Assert.AreEqual(Expected, actual);
        }

        [TestMethod]
        public void op_ExplicitTest6()
        {
            var p = new OptionParameter() { Value = "255" };

            const byte Expected = 255;

            var actual = (byte)p;

            Assert.AreEqual(Expected, actual);
        }

        [TestMethod]
        public void op_ExplicitTest7()
        {
            var p = new OptionParameter() { Value = "1" };

            const long Expected = 1L;

            var actual = (long)p;

            Assert.AreEqual(Expected, actual);
        }
    }
}